package com.tofine.smarthome.rest.service;

import com.tofine.smarthome.model.Category;
import com.tofine.smarthome.model.Device;
import com.tofine.smarthome.model.Room;
import com.tofine.smarthome.model.Scene;
import com.tofine.smarthome.rest.model.Command;

import java.util.List;

import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.DELETE;
import retrofit2.http.GET;
import retrofit2.http.Headers;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Path;

/**
 * @author ddMax
 * @since 2016/5/28 23:16
 * 说明：RESTful API 服务
 */
public interface ApiService {

    /* ----------------- Devices ----------------- */
    @GET("/api/devices")
    Call<List<Device>> getAllDevices();
    @GET("/api/devices/{id}")
    Call<Device> getDevice(@Path("id") String id);
    @POST("/api/devices")
    @Headers("Content-Type: application/json")
    Call<Device> createDevice(@Body Device device);
    @PUT("/api/devices/{id}")
    Call<Device> updateDevice(@Path("id") String id, @Body Device device);
    @DELETE("/api/devices/{id}")
    Call<Device> deleteDevice(@Path("id") String id);
    @GET("/api/devices/{id}/{command}")
    @Headers("Source: app")
    Call<Command> sendCommand(@Path("id") String id, @Path("command") String command);

    /* ----------------- Category ----------------- */
    @GET("/api/categories")
    Call<List<Category>> getAllCategories();
    @GET("/api/categories/{id}")
    Call<Category> getCategory(@Path("id") String id);
    @POST("/api/categories")
    @Headers("Content-Type: application/json")
    Call<Category> createCategory(@Body Category category);
    @PUT("/api/categories/{id}")
    Call<Category> updateCategory(@Path("id") String id);
    @DELETE("/api/categories/{id}")
    Call<Category> deleteCategory(@Path("id") String id);
    @GET("/api/categories/{id}/devices")
    Call<List<Device>> getCategoryDevices(@Path("id") String id);

    /* ----------------- Room ----------------- */
    @GET("/api/rooms")
    Call<List<Room>> getAllRooms();
    @GET("/api/rooms/{id}")
    Call<Room> getRoom(@Path("id") String id);
    @POST("/api/rooms")
    @Headers("Content-Type: application/json")
    Call<Room> createRoom(@Body Room room);
    @PUT("/api/rooms/{id}")
    Call<Room> updateRoom(@Path("id") String id);
    @DELETE("/api/rooms/{id}")
    Call<Room> deleteRoom(@Path("id") String id);
    @GET("/api/rooms/{id}/devices")
    Call<List<Device>> getRoomDevices(@Path("id") String id);

    /* ----------------- Scene ----------------- */
    @GET("/api/scenes")
    Call<List<Scene>> getAllScenes();
    @GET("/api/scenes/{id}")
    Call<Scene> getScene(@Path("id") String id);
    @POST("/api/scenes")
    Call<Scene> createScene(@Body Scene scene);
    @PUT("/api/scenes/{id}")
    Call<Scene> updateScene(@Path("id") String id);
    @DELETE("/api/scenes/{id}")
    Call<Scene> deleteScene(@Path("id") String id);
}
